package Package.IOStream.CharacterStream.Text.Text1;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class DataCopy {
    public static final void DataCopy() throws IOException {
//        案例需求
//把模块目录下的“ConversionStreamDemo.java” 复制到模块目录下的“Copy.java”
//实现步骤
//根据数据源创建字符输入流对象
//根据目的地创建字符输出流对象
//读写数据，复制文件
//释放资源D:\insert\javase\asd.java
//根据目的地创建字符输出流对象
        OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("D:\\insert\\javase\\asd.java"), StandardCharsets.UTF_8);
        InputStreamReader isr = new InputStreamReader(new FileInputStream("D:\\insert\\a.java"),StandardCharsets.UTF_8);
        char[] cha = new char[1024];
        int len;
        while ((len = isr.read(cha)) != -1) {
            osw.write(cha, 0, len);
        }
        osw.close();
        isr.close();

    }
}
